﻿using Rectangle;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestRectangle
{
    using Rectangle;

    [TestClass()]
    public class RectangleTest
    {
        [TestMethod()]
        public void RectangleConstructorTest()
        {
            int leftDownX = 96; // TODO: Initialize to an appropriate value
            int leftDownY = 54; // TODO: Initialize to an appropriate value
            int width = 56; // TODO: Initialize to an appropriate value
            int height = 1115; // TODO: Initialize to an appropriate value
            Rectangle target = new Rectangle(leftDownX, leftDownY, width, height);

            Assert.AreEqual<int>(leftDownX, target.LeftDownX, "LeftDownX is not set properly by the constructor");
            Assert.AreEqual<int>(leftDownY, target.LeftDownY, "LeftDownY is not set properly by the constructor");
            Assert.AreEqual<int>(width, target.Width, "Width is not set properly by the constructor");
            Assert.AreEqual<int>(height, target.Height, "Height is not set properly by the consturctor");
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException), "width and height of the rectangle cannot be negative numbers")]
        public void NegativeRecatngleWidthOrHeightInConstructor()
        {
            int leftDownX = 96; // TODO: Initialize to an appropriate value
            int leftDownY = 54; // TODO: Initialize to an appropriate value
            int width = -56; // TODO: Initialize to an appropriate value
            int height = 1115; // TODO: Initialize to an appropriate value
            Rectangle target = new Rectangle(leftDownX, leftDownY, width, height);
        }

        [TestMethod()]
        public void AreaTest()
        {
            int leftDownX = 96; // TODO: Initialize to an appropriate value
            int leftDownY = 54; // TODO: Initialize to an appropriate value
            int width = 56; // TODO: Initialize to an appropriate value
            int height = 1115; // TODO: Initialize to an appropriate value
            Rectangle target = new Rectangle(leftDownX, leftDownY, width, height); // TODO: Initialize to an appropriate value
            int expected = width * height; // TODO: Initialize to an appropriate value
            int actual = target.Area();
            Assert.AreEqual<int>(expected, actual, "The area method is not correct");
        }

        [TestMethod()]
        public void CloneTest()
        {
            int leftDownX = 65; // TODO: Initialize to an appropriate value
            int leftDownY = 54654; // TODO: Initialize to an appropriate value
            int width = 5465; // TODO: Initialize to an appropriate value
            int height = 545; // TODO: Initialize to an appropriate value
            Rectangle target = new Rectangle(leftDownX, leftDownY, width, height); // TODO: Initialize to an appropriate value
            Rectangle actual = (Rectangle)target.Clone();
            actual.LeftDownX--;
            Assert.AreNotEqual<int>(actual.LeftDownX, target.LeftDownX);
        }

        [TestMethod()]
        public void CompareToTest()
        {
            int leftDownX = 0; // TODO: Initialize to an appropriate value
            int leftDownY = 0; // TODO: Initialize to an appropriate value
            int width = 10; // TODO: Initialize to an appropriate value
            int height = 100; // TODO: Initialize to an appropriate value
            Rectangle target = new Rectangle(leftDownX, leftDownY, width, height); // TODO: Initialize to an appropriate value
            object obj = new Rectangle(leftDownX, leftDownX, width, height * 2); // TODO: Initialize to an appropriate value
            int expected = -1; // TODO: Initialize to an appropriate value
            int actual = target.CompareTo(obj);
            Assert.AreEqual(expected, actual, "The camparison af the are is not correct");
        }

        [TestMethod()]
        public void HeightTest()
        {
            int leftDownX = 0; // TODO: Initialize to an appropriate value
            int leftDownY = 0; // TODO: Initialize to an appropriate value
            int width = 99; // TODO: Initialize to an appropriate value
            int height = 999; // TODO: Initialize to an appropriate value
            Rectangle target = new Rectangle(leftDownX, leftDownY, width, height); // TODO: Initialize to an appropriate value
            int actual = target.Height;
            Assert.AreEqual<int>(actual, height);
        }

        [TestMethod()]
        public void LeftDownXTest()
        {
            int leftDownX = 445; // TODO: Initialize to an appropriate value
            int leftDownY = 5454; // TODO: Initialize to an appropriate value
            int width = 5454; // TODO: Initialize to an appropriate value
            int height = 554; // TODO: Initialize to an appropriate value
            Rectangle target = new Rectangle(leftDownX, leftDownY, width, height); // TODO: Initialize to an appropriate value
            target.LeftDownX--;
            int actual = target.LeftDownX;
            Assert.AreEqual<int>(leftDownX - 1, actual);
        }

        [TestMethod()]
        public void LeftDownYTest()
        {
            int leftDownX = 654645; // TODO: Initialize to an appropriate value
            int leftDownY = 545; // TODO: Initialize to an appropriate value
            int width = 5454; // TODO: Initialize to an appropriate value
            int height = 5454; // TODO: Initialize to an appropriate value
            Rectangle target = new Rectangle(leftDownX, leftDownY, width, height); // TODO: Initialize to an appropriate value
            target.LeftDownY++;
            int actual = target.LeftDownY;
            Assert.AreEqual<int>(leftDownY + 1, actual);
        }

        [TestMethod()]
        public void WidthTest()
        {
            int leftDownX = 0; // TODO: Initialize to an appropriate value
            int leftDownY = 0; // TODO: Initialize to an appropriate value
            int width = 9999; // TODO: Initialize to an appropriate value
            int height = 0; // TODO: Initialize to an appropriate value
            Rectangle target = new Rectangle(leftDownX, leftDownY, width, height); // TODO: Initialize to an appropriate value
            int actual = target.Width;
            Assert.AreEqual<int>(width, actual);
        }
    }
}
